<template>
  <el-dialog title="文件上传" :visible.sync="visible" :append-to-body="true" width="450px">
    <el-upload class="upload-demo" drag :action="uploadImg()" :on-success="handleAvatarSuccess"
    :file-list="this.fileList" :data="formData">
      <i class="el-icon-upload"></i>
      <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
    </el-upload>
  </el-dialog>

</template>


<script>
  /* eslint-disable */
  export default {
    data() {
      return {
        visible: false,
        type:3,
        fileList:[],
        formData: {
          type: 3,
          updateBy: this.$store.state.user.account
        }
      }
    },
    computed: {
      account: {
        get () { return this.$store.state.user.account },
        set (val) { this.$store.commit('user/updateAccount', val) }
      }
    },
    methods: {
      init(type) {
        this.visible = true
        // this.type = 3
      },
      uploadImg() {
        return this.$http.adornUrl('/excel/saveExcelFile');
      },
      handleAvatarSuccess(response) {
        if (response.success) {
          this.visible = false
          this.$emit('refreshDataList')
          this.$message.success("文件上传成功!")
        }else{
          this.$message.error(response.message)
        }
      },
    }
  }
</script>

<style lang="scss">
  .btn {
    margin-left: 100px;
  }
</style>
